home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / BF_SDK11.ZIP / ASM_DEMO.ASM next >
Assembly Source File  |  1996-05-21  |  2KB  |  76 lines

  1.  
  2. ;       ASM_DEMO.ASM
  3. ;       Assembler Test- and Demoprogram of the Compatibility 
  4. ;       (c)1996 Cedric Reinartz
  5.  
  6. ;     Simple programm which encrypts testdata and compares them with the
  7. ;    values provided by Bruce Schneier
  8.  
  9.  
  10.  
  11.     nopub     equ 1            ; we want to include BFENG386.ASM
  12.     useSmall equ 1            ; large model not needed
  13.     noLoop     equ 0            ; we don't need much speed
  14.     rnds     equ 1            ; 16 Rounds
  15.  
  16.     include bfe_asm.inc
  17.  
  18.     .data
  19.  
  20. key_0    dd 1058 dup(0)
  21.  
  22. ;   official Testvektors from DDJ 10/95... 
  23. PW_1        db "abcdefghijklmnopqrstuvwxyz"
  24. data1_p     dd 0424c4f57h, 046495348h
  25. data1_c     dd 0324ed0feh, 0f413a203h
  26. len_PW_1     equ offset data1_p - offset pw_1
  27.  
  28. PW_2        db "Who is John Galt?"
  29. data2_p     dd 0fedcba98h, 076543210h
  30. data2_c     dd 0cc91732bh, 08022f684h
  31. len_PW_2    equ offset data2_p - PW_2
  32.  
  33. noerror        db 13,10,10,"Test completed successfully !",13,10,"$"
  34. error        db 13,10,10,"Test failed !",13,10,"$"
  35.  
  36.     .code    
  37.  
  38. start:    _GetBoxPointer                ; mov dx,seg key_0 would also do
  39.     mov    ds,dx                ; load the right Datasegment
  40.  
  41.     _GetBoxes ds, <offset key_0>        ; Save original Boxes
  42.  
  43.     _InitCrypt ds,<offset PW_1>,len_PW_1    ; Set the first Password
  44.     _Encrypt ds,<offset data1_p>,8        ; Encrypt 8 Byte of Testdata
  45.     mov    si,offset data1_p        ; Compare with
  46.     call    comp                ; official values
  47.     jne    ko                ; Not equal -> Test Failed
  48.  
  49.     _SetBoxes ds, <offset key_0>        ; Restore original Boxes
  50.  
  51.     _InitCrypt ds,<offset PW_2>,len_PW_2    ; Set the second Password
  52.     _Encrypt ds,<offset data2_p>,8        ; Encrypt 8 Byte of Testdata
  53.     mov    si,offset data2_p        ; Compare with
  54.     call    comp                ; official values
  55.     jne    ko                ; Not equal -> Test Failed
  56.  
  57. OK:    mov    dx,offset noerror        ; Else: Test completed
  58.     jmp    finish
  59.  
  60. KO:    mov    dx,offset error
  61.  
  62. finish:    mov    ax,0900h            ; Show final message
  63.     int    21h
  64.     mov    ax,4c00h            ; Terminate programm
  65.     int    21h
  66.  
  67. comp:    mov    eax,[si]            ; Compares two DWords
  68.     cmp    eax,[si+8]            ; with the following
  69.     jne    c_end                ; two DWords
  70.     mov    eax,[si+4]
  71.     cmp    eax,[si+12]
  72. c_end:    ret
  73.  
  74.     end start
  75.  
  76.